package month_03.day22;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class Demo1 {
    public static class R1 implements Runnable{
        @Override
        public void run() {
            log.info("threadName:" + Thread.currentThread().getName());
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        ThreadGroup group=new ThreadGroup("thread-group-1");
        Thread t1=new Thread(group,new R1(),"T1");
        Thread t2=new Thread(group,new R1(),"T2");
        t1.start();
        t2.start();
        TimeUnit.SECONDS.sleep(1);
        log.info("活动线程数:" + group.activeCount());
        log.info("活动线程组:" + group.activeGroupCount());
        log.info("线程组名称:" + group.getName());
        log.info("threadName:" + Thread.currentThread().getName());
    }
}
